package com.miyake.loveviewweb.shared;

import java.util.ArrayList;
import java.util.List;

public class PluginType {
    public static final String REPORT = "Report";
    public static final String DATA_GENERATOR = "DataGenerator";
    public static final String FILE_PARSER = "FileParser";
    public static final String ANALYZER = "Analyzer";
    public static final String CHART = "Chart";
    public List<PluginTypeElement> getPlugins() {
        return plugins;
    }
    
    private List<PluginTypeElement> plugins = new ArrayList<PluginTypeElement>();
    private static PluginType instance = null;
    private PluginType() {
        plugins.add(new PluginTypeElement(CHART, CHART));
        plugins.add(new PluginTypeElement(ANALYZER, ANALYZER));
        plugins.add(new PluginTypeElement(FILE_PARSER, "File Parser"));
        plugins.add(new PluginTypeElement(DATA_GENERATOR, "Data Generator"));
        plugins.add(new PluginTypeElement(REPORT, REPORT));
    }
    
    public static PluginType getInstance() {
        if (instance == null) {
            instance = new PluginType();
        }
        return instance;
    }

    public String getCaption(String serviceType) {
        for (PluginTypeElement e : plugins) {
            if (e.getId().equals(serviceType)) {
                return e.getCaption();
            }
        }
        return null;
    }
}
